package cn.me.alphamq.common.enumeration;

/**
 * broker 的角色的枚举类
 *
 * @author f
 */
public enum BrokerRoleEnum {
    SINGLE("single"),
    MASTER("master"),
    SLAVE("slave");

    // 根据枚举的 code 属性获取枚举
    public static BrokerRoleEnum of(String code) {
        for (BrokerRoleEnum type : BrokerRoleEnum.values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new RuntimeException("invalid broker role code: " + code);
    }

    private final String code;

    BrokerRoleEnum(String code) {
        this.code = code;
    }

    public String getCode() {
        return code;
    }
}
